function factorial(num) {
  if (num < 1) {
    return 1
  } else {
    return num * arguments.callee(num - 1)
  }
}

console.log(factorial(8))

console.log('---------------------------------')

const fac = (function f(num) {
  if (num <= 1) {
    return 1
  } else {
    return num * f(num - 1)
  }
})

console.log(fac(12))

console.log('------------------------')
// 基础框架
function fib(n) {
  return fibImpl(0, 1, n)
}

// 执行递归
function fibImpl(a, b, n) {
  if (n === 0) {
    return a
  }
  console.log(`a: ${a}, b: ${b} n ${n}`)
  console.log('------------')
  return fibImpl(b, a + b, n - 1)
}

console.log(fib(10))
